package com.zcf.controller;

import com.zcf.common.json.Body;
import com.zcf.pojo.Pumping;
import com.zcf.service.PumpingServiceImpl;
import com.zcf.vo.out.LayuiJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author jj
 * @date 2019/11/11 15:50
 */
@CrossOrigin
@Controller
@RequestMapping("/pumping")
public class PumpingController {
    @Autowired
    private PumpingServiceImpl pumpingService;
    /**
    * @description :查询相关设置
    * @param gameType 
    * @date : 2019/11/23 14:05
    * @author : jj
    */
    @PostMapping("getPumping")
    @ResponseBody
    public LayuiJson getPumpingService(Integer gameType) {
        return pumpingService.getPumping(gameType);
    }
    /**
    * @description :修改相关设置
    * @date : 2019/11/23 14:11
    * @author : jj
    */
    @PostMapping("update" )
    @ResponseBody
    @Transactional(rollbackFor = Exception.class)
    public Body update(Pumping pumping){
        if ( pumping.getPumping() != null) {
            pumping.setPumping( pumping.getPumping());
        }
        boolean b = pumping.updateById();
        return b ? Body.newInstance():Body.newInstance(500,"参数错误");
    }
}
